package com.mylove.judas.yaya.mvp.presenter.impl;

import com.mylove.judas.yaya.common.http.ParamPost;
import com.mylove.judas.yaya.common.rx.subscriber.ProgressDialogSubscriber;
import com.mylove.judas.yaya.entity.BaseEntity;
import com.mylove.judas.yaya.mvp.model.ListModel;
import com.mylove.judas.yaya.mvp.presenter.BasePresenter;
import com.mylove.judas.yaya.mvp.presenter.contract.ListContract;
import com.mylove.judas.yaya.ui.App;

import java.util.List;

/**
 * Created by Judas on 2018/4/25.
 */

public class ListPresenter extends BasePresenter<ListModel, ListContract.ListView> {


    public ListPresenter(ListModel mModel, ListContract.ListView mView) {
        super(mModel, mView);
    }

    /**
     * 获取列表
     * @param type
     * @param index
     */
    public void getAll(int type, int index){

        ParamPost params = ParamPost.build().put("type", type).put("page", index);

        mModel.getAll(params, new ProgressDialogSubscriber<List<BaseEntity>>(App.getInstance()) {
            @Override
            public void onNext(List<BaseEntity> list) {
                mView.showListResult(list);
            }

            @Override
            public void onError(Throwable t) {
                super.onError(t);
                mView.showNoData();
            }
        });

    }

}
